class FoodGroup < ApplicationRecord
    has_attached_file :attachment,
                    styles: { image: "750x750>",thumb:'114x114>' },
                    path: ":rails_root/public/uploads/food_groups/:id/:style/:basename.:extension",
                    url: "/uploads/food_groups/:id/:style/:basename.:extension"
    has_many :food_group_items,dependent: :destroy
    has_many :foods,through: :food_group_items
    has_many :order_items,dependent: :destroy
    validates_attachment_content_type :attachment, content_type: /\Aimage\/.*\Z/


    def show_price
        foods.to_a.sum{|item| item.show_price}
    end    


    
end
